Last active
July 9, 2020 19:52
-
-
Save marketinview/122ae16c199b320ba1815251aa372c7f to your computer and use it in GitHub Desktop.
Excel: Concat vb function to concatenate a range of cells. Note: In newer versions of Excel (e.g. Office 365) the built-in TEXTJOIN feature can be used instead. #excel #vb #concatenate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Concat(rng As Range, Optional sep As String = ",") As String | |
Dim rngCell As Range | |
Dim strResult As String | |
For Each rngCell In rng | |
If rngCell.Value <> "" Then | |
strResult = strResult & sep & rngCell.Value | |
End If | |
Next rngCell | |
If strResult <> "" Then | |
strResult = Mid(strResult, Len(sep) + 1) | |
End If | |
Concat = strResult | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment